<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%
String userName = (String)request.getSession().getAttribute((String)com.wing.common.Constants.SESSION_SITE_USER_NAME);
String userId = (String)request.getSession().getAttribute((String)com.wing.common.Constants.SESSION_SITE_USER_ID);
%>
<script type="text/javascript">
	function login(){
		opendailog1("{id:'loginwin',src:'stlogin',title:'用户登录',width:400,height:350}");
	}
	function logout(){
		$.ajax({
			url :"<%=path%>/ext/site_user/logout", //要访问的后台地址
		    type : 'post', //使用get方法访问后台
		    success : function(data){
	   			document.location.reload();
		    }
		});	 
	}
	function zhuce(){
		opendailog1("{id:'loginwin',src:'register',title:'用户注册',width:540,height:380}");
	}
	
	var mgrmysite = function(){
  		$.ajax({
		   type: "POST",
		   url: "/sys/dispatch",   
		   data: "login_code=ybl_<%=userName %>",
		   dataType: 'json',
		   success: function(data){
		     	if(data.status=="failure"){
					if(data.code=="nosite"){
						alert("对不起您还没有自己的网站！");
					}
				}else{
					window.location="http://"+data.url+"/sys/get/login?a=y&l="+data.l+"&p="+data.p;
				}
		   }
		}); 
	}
	var openmysite = function(){
  		$.ajax({
		   type: "POST",
		   url: "/sys/dispatch",   
		   data: "login_code=ybl_<%=userName %>",
		   dataType: 'json',
		   success: function(data){
		     	if(data.status=="failure"){
					if(data.code=="nosite"){
						alert("对不起您还没有自己的网站！");
					}
				}else{
					window.location="http://"+data.url;
				}
		   }
		}); 
	}
</script>
<div class="land">
  <div class="land_main"><span class="left">您好！ 欢迎光临雅宝路信息网</span> <bdo class="left">&nbsp;&nbsp;
  	<%if(userId!=null){
  		%>
  		<%=userName %><a href="#" onclick="logout()" class="cred">退出</a>
  		<a href="#" onclick="mgrmysite()" class="cred">管理我的网站</a>
  		<a href="#" onclick="openmysite()" class="cred">进入我的网站</a>
  		<%
  	}else{
  		%>
  		<a href="#" onclick="login()" class="cred">登录</a><a href="#" onclick="zhuce()" class="cred">免费注册</a>
  	<%
  	} 
  	%>
  	</bdo>
  </div>	
</div>
